<?PHP

class SiteBlackoutBO extends BusinessObject{
  /* private function using in constructors*/
  function setAttributes(){
    $this->fields   = array(
			id                =>	sites_blackout_id,
			site_id           =>	sites_blackout_siteid,
			startdate         =>	sites_blackout_startdate,
			finishdate        =>	sites_blackout_finishdate,
			descr				=>	sites_blackout_descr
		);

    BusinessObject::setAttributes();
  }
  /* constuctor */
  function SiteBlackoutBO(){
    /** super(tableName) */
    BusinessObject::BusinessObject("sites_blackout");
    $this->setAttributes();
  }
  
  //format of date  "2007-12-31"
  //return true if date in blackout period
	function isBlackout($site_id,$date_to_check) {
    	$sd = new SiteBlackoutBO();
		$sd->site_id = $site_id;
		$where = "('".$date_to_check."' <".$sd->fields["finishdate"]." and '".$date_to_check."' >=".$sd->fields["startdate"].")";
		if ($sd->getCount($where) > 0)
			return true;
		else
			return false;
	}
}
?>
